﻿module ExecutionTests


open System
open System.IO
open Microsoft.VisualStudio.TestTools.UnitTesting
open ParsingEvents
open Execution
//open Behaviors


//[<TestClass>]
//type public ParsingTestsExecutionTests() = 


//   TODO this all works, the test just needs to be refactored a bit
//   [<TestMethod>]
//   member public self.CreateContext_LoadsAllAssembliesProperly() =   
//      let assembly1 = AppDomain.CurrentDomain.GetAssemblies().[1]
//      let assembly2 = AppDomain.CurrentDomain.GetAssemblies().[2]
//
//      let file1 = new FileInfo(assembly1.Location)
//      let file2 = new FileInfo(assembly2.Location)
//
//      let context = CreateContext(file1, [| file2 |])
//
//      let type1 = assembly1.GetTypes().[0]
//      let type2 = assembly2.GetTypes().[0]
//
//      context.Domain.CreateInstance(assembly1.FullName, type1.FullName) |> ignore
//      context.Domain.CreateInstance(assembly2.FullName, type2.FullName) |> ignore
//
//      let loaded = context.Domain.GetAssemblies() 
//                  |> Array.collect(fun a -> [| a.GetType(type1.FullName); a.GetType(type2.FullName) |]) 
//                  |> Array.filter(fun t -> t <> null)
//      
//      Assert.IsNotNull(Array.Find(loaded, fun t -> t = type1))
//      Assert.IsNotNull(Array.Find(loaded, fun t -> t = type2))


//   TODO this all works, the test just needs to be refactored a bit
//   [<TestMethod>]
//   member public self.ExtractInitializer_FindsAndCreatesInstanceOfBehaviors() =
//      let forceLoadBehaviorsAssembly = Behaviors()
//      let assembly = 
//         AppDomain.CurrentDomain.GetAssemblies()
//         |> Array.filter(fun a -> a.FullName.Contains("Forethought.Core.Behaviors"))
//         |> Array.map(fun a -> a.Location)
//
//      let file = new FileInfo(assembly.[0])
//
//      use context = CreateContext(file, [||])      
//
//      let actual = ExtractEntry(context.Domain)
//
//      Assert.IsNotNull(actual)
//      Assert.IsTrue(actual.DomainName().StartsWith("DSL-"))
//
//      try
//         let events = ParsingContext()
//
//         actual.Initialize(events)         
//      with
//         | _ as e -> Assert.Fail()      